//package com.canal.mq.listener;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.canal.constant.CanalConstants;
//import com.canal.util.RedisUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
//import org.apache.rocketmq.common.message.MessageExt;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//import java.util.concurrent.ArrayBlockingQueue;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.ThreadPoolExecutor;
//import java.util.concurrent.TimeUnit;
//
///**
// * @author wang
// */
//@Component
//@Slf4j
//public class CanalListener implements MessageListenerConcurrently {
//
//    private final int nThreads = 5;
//    private final int maxThreads = 100;
//    private final int MAX_QUEUQ_SIZE = 2000;
//    private final ExecutorService executor = new ThreadPoolExecutor(nThreads,
//            maxThreads, 0L, TimeUnit.MILLISECONDS,
//            new ArrayBlockingQueue<Runnable>(MAX_QUEUQ_SIZE),
//            new ThreadPoolExecutor.CallerRunsPolicy());
//
//    @Autowired
//    private RedisUtil redisUtil;
//
//    @Override
//    public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgList, ConsumeConcurrentlyContext context) {
//        for (MessageExt messageExt : msgList) {
//            log.info("【消费者MQ收到消息】, MsgId = {}，Topic = {}，Tags = {}，keys = {}",
//                    messageExt.getMsgId(), messageExt.getTopic(), messageExt.getTags(), messageExt.getKeys());
//            byte[] body = messageExt.getBody();
//            String res = new String(body);
//            log.info("收到消息内容 = {}", res);
//            JSONObject jsonObject = JSON.parseObject(res);
//            System.out.println(jsonObject);
//            System.out.println("==============================");
//            String sqlType = jsonObject.getString("type");
//            System.out.println(sqlType);
//        }
//        return ConsumeConcurrentlyStatus.RECONSUME_LATER;
//    }
//
//}
